//login.js
//获取应用实例
var app=getApp();
Page({
  data: {
    remind: '加载中',
    help_status: false,
    userid_focus: false,
    passwd_focus: false,
    userid: '',
    passwd: '',
    user:'',
    pass:'',
    angle: 0
  },
  onReady: function(){
    var _this = this;
    setTimeout(function(){
      _this.setData({
        remind: ''
      });
    }, 1000);
    wx.onAccelerometerChange(function(res) {
      var angle = -(res.x*30).toFixed(1);
      if(angle>14){ angle=14; }
      else if(angle<-14){ angle=-14; }
      if(_this.data.angle !== angle){
        _this.setData({
          angle: angle
        });
      }
    });
  },
  //数据库里面数据与缓存数据进行比较
  bind: function() {
     //调用云数据库
     var userid=this.data.userid;
     var passwd=this.data.passwd;
      // wx.request({
      //   url: 'http://localhost:8080/in/information', //本地服务器地址
      //   method:
      //   'GET',
      //    header:{
      //      'content-type':'application/json' //默认值
      //     },
      //     success:(result) => {
      //       console.log(result.data)
      //       this.setData({
      //         user:result.data
      //         pass:result.data
      //       })
      //     }
      // })
      app.globalData.denlu=true;
        wx.showToast({
          title: '恭喜你登录成功',
        })
  },
  useridInput: function(e) {
    this.setData({
      userid: e.detail.value
    });
    if(e.detail.value.length >= 7){
      wx.hideKeyboard();
    }
  },
  passwdInput: function(e) {
    this.setData({
      passwd: e.detail.value
    });
  },
  inputFocus: function(e){
    if(e.target.id == 'userid'){
      this.setData({
        'userid_focus': true
      });
    }else if(e.target.id == 'passwd'){
      this.setData({
        'passwd_focus': true
      });
    }
  },
  inputBlur: function(e){
    if(e.target.id == 'userid'){
      this.setData({
        'userid_focus': false
      });
    }else if(e.target.id == 'passwd'){
      this.setData({
        'passwd_focus': false
      });
    }
  },
  tapHelp: function(e){
    if(e.target.id == 'help'){
      this.hideHelp();
    }
  },
  showHelp: function(e){
    this.setData({
      'help_status': true
    });
  },
  hideHelp: function(e){
    this.setData({
      'help_status': false
    });
  },
  tiaozhuan:function(){
    wx.switchTab({
      url: 'my',
    })
   }
});